﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using LogisticsDAL;
using Model;
using System.Data.SqlClient;

namespace LogisticsBLL
{
    public class TruckBLL
    {
        public static DataTable Truread(int pageIndex, int pageSize, out int Recout, string truckName, string Leader)
        {
            return TruckDAL.Trucklist(pageIndex,pageSize,out Recout,truckName,Leader);
        }

        /// <summary>
        /// 查询车队详细信息
        /// </summary>
        /// <returns></returns>
        public static DataTable TruckSel(string truckname, string leader)
        {
            TruckDAL td = new TruckDAL();
            return TruckDAL.Truckread(truckname,leader);
        }


        /// <summary>
        /// 删除信息
        /// </summary>
        /// <param name="CattrueckID"></param>
        /// <returns></returns>
        public static int TruckDel(int CattrueckID)
        {
            return TruckDAL.delTruck(CattrueckID);
        }

        public static int TruckUpdate(int CattrueckIDs,string reamke)
        {
            return TruckDAL.UpdatTruck(CattrueckIDs,reamke);
        }

        /// <summary>
        /// 车辆信息管理，绑定车辆信息
        /// </summary>
        /// <returns></returns>
        public static DataTable BindCar(int pageIndex, int pagesize, out int Count, string CarNum, string CarTeamName, string Type, string State)
        {
           
           return TruckDAL.BindCar(pageIndex,pagesize, out Count,CarNum,CarTeamName,Type,State);
            
        }

        /// <summary>
        /// 车辆信息页面三个下拉框
        /// </summary>
        /// <returns></returns>
        public DataTable ddlbindCarName()
        {
            TruckDAL tru = new TruckDAL();
            return tru.ddlbindCarTeam();
        }
        public DataTable ddlbindCarState()
        {
            TruckDAL tru = new TruckDAL();
            return tru.ddlbindCarState();
        }
        public DataTable ddlbindCarType()
        {
            TruckDAL tru = new TruckDAL();
            return tru.ddlbindCarType();
        }

        /// <summary>
        /// 车辆条件查询
        /// </summary>
        /// <param name="CarNum"></param>
        /// <param name="CarTeamName"></param>
        /// <param name="Type"></param>
        /// <param name="State"></param>
        /// <returns></returns>
        public DataTable Gvselect(string CarNum, string CarTeamName, string Type, string State)
        {
            TruckDAL tru = new TruckDAL();
            return tru.sqlreadCar(CarNum,CarTeamName,Type,State);
        }


        public int AddTruckTeam(string teaName, string Leadr, string Reamrk)
        {
            TruckDAL tru = new TruckDAL();
            TruckTeam team = new TruckTeam();
            return tru.AddTruckTream(teaName, Leadr, Reamrk);
        }

        public int AddTruck(string Number, string BuyDate, string Types, string Length, string Tonnge, int teamid, string Reamrk)
        {
            TruckDAL tru = new TruckDAL();
            TruckTeam team = new TruckTeam();
            return tru.AddTruck(Number,BuyDate, Types,Length,Tonnge,teamid,Reamrk);
        }


        public Trucks BIndturck(int id)
        {
            TruckDAL trud = new TruckDAL();
            return trud.bindtruck(id);
        }

        /// <summary>
        /// 修改车辆信息
        /// </summary>
        /// <param name="trs"></param>
        /// <returns></returns>
        public int updatruck(Trucks trs)
        {
            TruckDAL tru = new TruckDAL();
            return tru.updaTruck(trs);
        }

        /// <summary>
        /// 删除车辆信息
        /// </summary>
        /// <param name="tid"></param>
        /// <returns></returns>
        public int deletTruck(int tid)
        {
            TruckDAL td = new TruckDAL();
            return td.deletTruck(tid);
        }

        public bool readtru(int readid)
        {
            TruckDAL td = new TruckDAL();
            return td.readstruck(readid);
        }





        public List<Trucks> read()
        {
            TruckDAL tus = new TruckDAL();
            return tus.read();
        }


        public List<Trucks> readNumber(int TeamID)
        {
            TruckDAL tus = new TruckDAL();
            return tus.readNumber(TeamID);
        }

        public SqlDataReader readTruckSel(int TeamID)
        {
            TruckDAL td = new TruckDAL();
            return td.truckSelect(TeamID);
        }
    }
}
